home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performSetKeyframeArgList.me < prev    next >
Encoding:
Text File  |  2003-07-17  |  11.4 KB  |  450 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Dec 3, 1996
  22. //
  23. //  Description:
  24. //      This is a helper script to perform the setKeyframe command
  25. //    using the various options that have been set
  26. //
  27. //  Input Arguments:
  28. //        int action        0 - just execute the command
  29. //                        1 - show the option box dialog
  30. //                        2 - return the drag command
  31. //
  32. //  Return Value:
  33. //      None.
  34. //
  35.  
  36. proc setOptionVars (int $forceFactorySettings)
  37. {
  38.     // setKeyframeWhich:
  39.     //     1 : set keyframes on all keyable attrs
  40.     //     2 : set keyframes on all manip handle attrs
  41.     //     3 : set keyframes on current manip handle
  42.     //   4 : set keyframes on all manip handle attrs and all keyable attrs
  43.     //
  44.     if( $forceFactorySettings || !`optionVar -exists setKeyframeWhich` ) {
  45.         optionVar -intValue setKeyframeWhich 4;
  46.     } 
  47.  
  48.     if( $forceFactorySettings || !`optionVar -exists setKeyframePrompt` ) {
  49.         optionVar -intValue setKeyframePrompt 0;
  50.     } 
  51.  
  52.     if ( $forceFactorySettings || !`optionVar -exists keySetIKFK` ) {
  53.         optionVar -intValue keySetIKFK 0;
  54.     }
  55.  
  56.     if( $forceFactorySettings || !`optionVar -exists keyHierarchy`) {
  57.         optionVar -intValue keyHierarchy 0;
  58.     }
  59.     // use channel box attrs
  60.     //
  61.     if ($forceFactorySettings || !`optionVar -exists keyUseChannelBox`) {
  62.         optionVar -intValue keyUseChannelBox 0;
  63.     }
  64.     // -controlPoints
  65.     //
  66.     if ($forceFactorySettings || !`optionVar -exists keyControlPoints`) {
  67.         optionVar -intValue keyControlPoints 0;
  68.     }
  69.     // -shape
  70.     //
  71.     if ($forceFactorySettings || !`optionVar -exists keyShapes`) {
  72.         optionVar -intValue keyShapes 1;
  73.     }
  74. }
  75.  
  76. global proc setKeyframeSetup (string $parent, int $forceFactorySettings)
  77. {
  78.     // Retrieve the option settings
  79.     //
  80.     setOptionVars( $forceFactorySettings );
  81.  
  82.     setParent $parent;
  83.  
  84.     // Query the optionVar's and set the values into the controls
  85.     //    
  86.     int $whichAttrs = `optionVar -query setKeyframeWhich`;
  87.     switch($whichAttrs)
  88.     {
  89.         case 1:
  90.             radioButtonGrp -edit -sl 1 allAttrsRB;
  91.             break;
  92.         case 2:
  93.             radioButtonGrp -edit -sl 1 allManipAttrsRB;
  94.             break;
  95.         case 3:
  96.             radioButtonGrp -edit -sl 1 curManipHandleRB;
  97.             break;
  98.         case 4:
  99.             radioButtonGrp -edit -sl 1 allManipOrAttrsRB;
  100.             break;
  101.     }
  102.  
  103.     if( `optionVar -query setKeyframePrompt` == 1 ) {
  104.         radioButtonGrp -e -select 2 setKeyframePrompt;
  105.     } else {
  106.         radioButtonGrp -e -select 1 setKeyframePrompt;
  107.     }
  108.  
  109.     checkBoxGrp -edit -value1 `optionVar -query keySetIKFK` setIKFKCB;
  110.  
  111.     if (`optionVar -query keyHierarchy` == 1) {
  112.         radioButtonGrp -edit -select 2 hierarchyRB;
  113.     } else {
  114.         radioButtonGrp -edit -select 1 hierarchyRB;
  115.     }
  116.  
  117.     if (`optionVar -query keyUseChannelBox` == 1) {
  118.         radioButtonGrp -edit -select 2 channelsRB;
  119.     } else {
  120.         radioButtonGrp -edit -select 1 channelsRB;
  121.     }
  122.  
  123.     checkBoxGrp -edit -value1 `optionVar -query keyControlPoints` controlCB;
  124.     checkBoxGrp -edit -value1 `optionVar -query keyShapes` shapesCB;
  125.  
  126.     keyEnabling $parent ($whichAttrs == 1);
  127. }
  128.  
  129. global proc setKeyframeCallback (string $parent, int $doIt, string $selectionConnection)
  130. //
  131. // Description:
  132. //    Set the optionVar's from the control values, and then perform
  133. //    the command
  134. //
  135. {
  136.     setParent $parent;
  137.  
  138.     if( `radioButtonGrp -q -sl allManipAttrsRB` == 1) {
  139.         optionVar -intValue setKeyframeWhich 2;
  140.     } else if( `radioButtonGrp -q -sl curManipHandleRB` == 1 ) {
  141.         optionVar -intValue setKeyframeWhich 3;
  142.     } else if( `radioButtonGrp -q -sl allAttrsRB` == 1 ) {
  143.         optionVar -intValue setKeyframeWhich 1;
  144.     } else {
  145.         optionVar -intValue setKeyframeWhich 4;
  146.     }
  147.  
  148.     if (`radioButtonGrp -query -select setKeyframePrompt` == 2) {
  149.         optionVar -intValue setKeyframePrompt 1;
  150.     } else {
  151.         optionVar -intValue setKeyframePrompt 0;
  152.     }
  153.  
  154.     optionVar -intValue keySetIKFK `checkBoxGrp -query -value1 setIKFKCB`;
  155.  
  156.     if (`radioButtonGrp -query -select hierarchyRB` == 2) {
  157.         optionVar -intValue keyHierarchy 1;
  158.     } else {
  159.         optionVar -intValue keyHierarchy 0;
  160.     }
  161.  
  162.     if (`radioButtonGrp -query -select channelsRB` == 2) {
  163.         optionVar -intValue keyUseChannelBox 1;
  164.     } else {
  165.         optionVar -intValue keyUseChannelBox 0;
  166.     }
  167.  
  168.     optionVar -intValue keyControlPoints
  169.                             `checkBoxGrp -query -value1 controlCB`;
  170.     optionVar -intValue keyShapes
  171.                             `checkBoxGrp -query -value1 shapesCB`;
  172.  
  173.     if ($doIt)
  174.     {    
  175.         string $args[] = {(string)
  176.             0,
  177.             $selectionConnection
  178.         };
  179.  
  180.         performSetKeyframeArgList 1 $args;
  181.         string $tmpCmd = "performSetKeyframeArgList 1 " + "{ \"0\", ";
  182.         $tmpCmd += "\"" + $selectionConnection + "\"}";
  183.         addToRecentCommandQueue $tmpCmd "SetKeyframe";
  184.     }
  185. }
  186.  
  187.  
  188. global proc keyEnabling(string $parent, int $state)
  189. {
  190.     setParent $parent;
  191.  
  192.     radioButtonGrp -edit -enable $state hierarchyRB;
  193.     radioButtonGrp -edit -enable $state channelsRB;
  194.  
  195.     keyChannelsEnabling $parent 
  196.         ($state && (`radioButtonGrp -query -select channelsRB` == 1));
  197. }
  198.  
  199. global proc keyChannelsEnabling(string $parent, int $state)
  200. {
  201.     setParent $parent;
  202.  
  203.     checkBoxGrp -edit -enable $state controlCB;
  204.     checkBoxGrp -edit -enable $state shapesCB;
  205. }
  206.  
  207. global proc keyIKFKEnabling(string $parent, int $state)
  208. {
  209.     setParent $parent;
  210.     checkBoxGrp -edit -enable $state setIKFKCB;
  211. }
  212.  
  213. proc string setKeyframeWidgets( string $parent )
  214. {
  215.     setParent $parent;
  216.     
  217.     string $tabForm = `columnLayout -adjustableColumn true`;
  218.  
  219.     // Make a collection of 4 radio groups instead of one with 4 options,
  220.     // so that we can line up the text on separate lines
  221.     //
  222.     radioButtonGrp -numberOfRadioButtons 1
  223.         -cw2 170 400
  224.         -label "Set Keys on"
  225.         -label1 "All Manipulator Handles and Keyable Attributes"
  226.         allManipOrAttrsRB;
  227.     
  228.     radioButtonGrp -numberOfRadioButtons 1
  229.         -cw2 170 400        
  230.         -label1 "All Keyable Attributes"
  231.         -cc ("keyEnabling "+ $parent+" #1")
  232.         -shareCollection allManipOrAttrsRB
  233.         allAttrsRB;
  234.     
  235.     radioButtonGrp -numberOfRadioButtons 1
  236.         -cw2 170 400        
  237.         -label1 "All Manipulator Handles"
  238.         -shareCollection allManipOrAttrsRB
  239.         allManipAttrsRB;
  240.  
  241.     radioButtonGrp -numberOfRadioButtons 1
  242.         -cw2 170 400        
  243.         -label1 "Current Manipulator Handle"
  244.         -shareCollection allManipOrAttrsRB
  245.         curManipHandleRB;
  246.  
  247.     radioButtonGrp -numberOfRadioButtons 2
  248.         -cw3 170 160 200
  249.         -label  "Set Keys at"
  250.         -label1 "Current Time" 
  251.         -label2 "Prompt"
  252.         -cc1 ("keyIKFKEnabling "+ $parent+" #1")
  253.         setKeyframePrompt;
  254.  
  255.     checkBoxGrp -label "Set IK/FK Keys" -ncb 1 -label1 "" setIKFKCB;
  256.  
  257.     separator -style "in";
  258.  
  259.     radioButtonGrp -numberOfRadioButtons 2
  260.         -cw3 170 160 200        
  261.            -label Hierarchy -label1 "Selected" -label2 "Below"
  262.            hierarchyRB;
  263.  
  264.     radioButtonGrp -numberOfRadioButtons 2 -label "Channels"
  265.         -cw3 170 160 200        
  266.                 -label1 "All Keyable" 
  267.                 -label2 "From Channel Box"
  268.                 -cc1 ("keyChannelsEnabling " + $parent + " #1")
  269.                 channelsRB;
  270.  
  271.     checkBoxGrp -label "Control Points" -ncb 1 -label1 "" controlCB;
  272.     checkBoxGrp -label "Shapes" -ncb 1 -label1 "" shapesCB;
  273.  
  274.     return $tabForm;
  275. }
  276.  
  277. global proc setKeyframeOptions (string $selectionConnection)
  278. {
  279.     string $commandName = "setKeyframe";
  280.  
  281.     string $applyTitle = "Set Key";
  282.     
  283.     // Build the option box "methods"
  284.     //
  285.     string $callback = ($commandName + "Callback");
  286.     string $setup = ($commandName + "Setup");
  287.  
  288.     //    Get the option box.
  289.     //
  290.     //  The value returned is the name of the layout to be used as
  291.     //    the parent for the option box UI.
  292.     //
  293.     string $layout = getOptionBox();
  294.     setParent $layout;
  295.  
  296.     setOptionBoxCommandName($commandName);
  297.  
  298.     setUITemplate -pushTemplate DefaultTemplate;
  299.     waitCursor -state 1;
  300.     tabLayout -scr true -tv false;    // To get the scroll bars
  301.  
  302.     string $parent = `columnLayout -adjustableColumn 1`;
  303.  
  304.     setKeyframeWidgets $parent;
  305.  
  306.     waitCursor -state 0;
  307.     setUITemplate -popTemplate;
  308.  
  309.     //    'Apply' button.
  310.     //
  311.     string $applyBtn = getOptionBoxApplyBtn();
  312.     button -edit
  313.         -label $applyTitle
  314.         -command ($callback + " " + $parent + " " + 1 + " \"" + $selectionConnection + "\"")
  315.         $applyBtn;
  316.  
  317.     //    'Save' button.
  318.     //
  319.     string $saveBtn = getOptionBoxSaveBtn();
  320.     button -edit 
  321.         -command ($callback + " " + $parent + " " + 0 + " \"" + $selectionConnection + "\"; hideOptionBox")
  322.         $saveBtn;
  323.  
  324.     //    'Reset' button.
  325.     //
  326.     string $resetBtn = getOptionBoxResetBtn();
  327.     button -edit 
  328.         -command ($setup + " " + $parent + " " + 1)
  329.         $resetBtn;
  330.  
  331.     //    Set the option box title.
  332.     //
  333.     setOptionBoxTitle("Set Key Options");
  334.  
  335.     //    Customize the 'Help' menu item text.
  336.     //
  337.     setOptionBoxHelpTag( "SetKey" );
  338.  
  339.     //    Set the current values of the option box.
  340.     //
  341.     eval (($setup + " " + $parent + " " + 0));    
  342.     
  343.     //    Show the option box.
  344.     //
  345.     showOptionBox();
  346. }
  347.  
  348.  
  349. //
  350. //  Procedure Name:
  351. //      assembleCmd
  352. //
  353. //  Description:
  354. //        Construct the command that will apply the option box values.
  355. //
  356. //  Input Arguments:
  357. //      None.
  358. //
  359. //  Return Value:
  360. //      None.
  361. //
  362. proc string assembleCmd (string $selectionConnection)
  363. {
  364.     string $cmd;
  365.  
  366.     setOptionVars(false);
  367.  
  368.     // doSetKeyframeArgList takes a string array 
  369.     //
  370.     $cmd =    "doSetKeyframeArgList 4 { " +
  371.                 "\"" + `optionVar -query setKeyframeWhich` + "\"" +
  372.                 ",\"" + `optionVar -query keyHierarchy` + "\"" +
  373.                 ",\"" + `optionVar -query keyUseChannelBox` + "\"" +
  374.                 ",\"" + `optionVar -query keyControlPoints` + "\"" +
  375.                 ",\"" + `optionVar -query keyShapes` + "\"" +
  376.                 ",\"" + `optionVar -query setKeyframePrompt` + "\"" +
  377.                 ",\"" + false + "\"" +
  378.                 ",\"" + $selectionConnection + "\"" +
  379.                 ",\"" + `optionVar -query keySetIKFK` + "\"" +
  380.             " };";
  381.  
  382.     return $cmd;
  383. }
  384.  
  385. global proc string
  386. performSetKeyframeArgList (string $version, string $args[])
  387. //
  388. //  Input Arguments:
  389. //    $version: The version of this option box.  Used to know how to 
  390. //    interpret the $args array.
  391. //        "1" : $action, $selectionConnection
  392. //
  393. //    $args
  394. //    Version 1
  395. //    [0]        $action                    0 - do the command
  396. //                                    1 - show the option box
  397. //                                    2 - return the drag command
  398. //    [1]        $selectionConnection    name of selection connection to use
  399. //
  400. //  Return Value:
  401. //      The actual command to execute.
  402. //
  403. {
  404.     int        $versionNum                = $version;
  405.  
  406.     int        $action                    = $args[0];
  407.     string    $selectionConnection    = $args[1];
  408.  
  409.     string $cmd = "";
  410.  
  411.     switch ($action) {
  412.  
  413.         //    Execute the command.
  414.         //
  415.         case 0:
  416.             //    Retrieve the option settings
  417.             //
  418.             setOptionVars(false);
  419.  
  420.             //    Get the command.
  421.             //
  422.             $cmd = assembleCmd ($selectionConnection);
  423.  
  424.             //    Execute the command with the option settings.
  425.             //
  426.             eval($cmd);
  427.  
  428.             break;
  429.  
  430.         //    Show the option box.
  431.         //
  432.         case 1:
  433.             setKeyframeOptions ($selectionConnection);
  434.             break;
  435.  
  436.         //    Return the command string.
  437.         //
  438.         case 2:
  439.             //    Retrieve the option settings.
  440.             //
  441.             setOptionVars (false);
  442.  
  443.             //    Get the command.
  444.             //
  445.             $cmd = assembleCmd ($selectionConnection);
  446.             break;
  447.     }
  448.     return $cmd;
  449. }
  450.